#! -*-encoding=utf-8-*-
import requests


class WeatherINFO:

    def __init__(self):
        self.weather_url = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"

    def getSupportCity(self, byProvinceName):
        xml_data = f'''<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
        <getSupportCity
            xmlns="http://WebXml.com.cn/">
            <byProvinceName>{byProvinceName}</byProvinceName>
        </getSupportCity>
    </soap12:Body>
</soap12:Envelope>'''.encode("utf-8")
        return requests.post(url=self.weather_url,
                             headers={"Content-Type": "application/soap+xml; charset=utf-8"},
                             data=xml_data)


if __name__ == '__main__':
    weatherinfo = WeatherINFO()
    response = weatherinfo.getSupportCity("河北")
    print(response.text)
